import {
  createStore
} from 'vuex'

export default createStore({
  state: {
    list: [{
        title: "吃饭",
        complete: false,
      },
      {
        title: "睡觉",
        complete: false,
      },
      {
        title: "学习",
        complete: true,
      },
    ]
  },
  mutations: {
    // 添加任务列表  新增的对象
    addTodo(state, payload) {
      state.list.push(payload)
    },
    // 删除任务  下标
    delTodo(state, payload) {
      state.list.splice(payload, 1)
    },
    // 删除已完成, 过滤之后剩余的list
    clear(state, payload) {
      state.list = payload
    }

  },
  actions: {},
  modules: {}
})